﻿
namespace TOPTECH.Labs.OpenClosed.Correct.Strategies
{
    using System.Collections.Generic;
    using System.Text;

    public class AgeGroup
    {
        private static List<IAgeGroup> AgeGroups = new List<IAgeGroup> {
          new Child(),
          new Adult()
        };

        private int age;

        public AgeGroup(int age)
        {
            this.age = age;
        }

        public override string ToString()
        {
            var result = "being";
            var allAgeGroups = new List<string>();
                     
            foreach (IAgeGroup ageGroup in AgeGroups)
            {
                if (ageGroup.Condition(this.age))
                {
                    allAgeGroups.Add(ageGroup.GetText());
                }
            }

            if (allAgeGroups.Count > 0)
            {
                result = string.Join(" ", allAgeGroups);
            }

            return result;
        }
    }
}
